home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / vlapak1.zip / MXFONT.ZIP / MXFONT.INC < prev    next >
Text File  |  1993-06-27  |  4KB  |  199 lines

  1. ;
  2. ; Order of operation:
  3. ; 1) Call StealFont (grabs 8x8 bios font)
  4. ; 2) Change into any 256 color PLANAR mode
  5. ; 3) Call SetDefPal, which sets up the default palette useing the last
  6. ;       few palette registers.  This is not neccessary, but if you want 
  7. ;       to use the predefined colors, it is needed.
  8. ; ?) Call PrintText to print a message
  9. ;       DI = Ypos, AX = Xpos, DS:SI -> zero terminating string to process.
  10. ;       1 = change color command. 2->255 are characters. no line feeds or
  11. ;       carriage returns.
  12. ; OR
  13. ; ?) Call PrintList, which will print out a list of messages all across the
  14. ;       screen. DS:BX -> the MsgHdr's
  15. ;
  16. ; NOTE: The Y position is in PIXELS, the X position is in 4 pixel increments.
  17. ;       All characters are 8 pixels wide. (2 X positions.)
  18. ;       This code is set up for IDEAL mode.
  19. ;
  20. ;   Written by Draeden of VLA
  21. ;
  22. ────────────────────────────────────────────────────────────────────────────
  23. STRUC PalStruc
  24.     R   db  ?
  25.     G   db  ?
  26.     B   db  ?
  27. ENDS
  28.  
  29. STRUC MsgHdr
  30.     Off     dw  ?
  31.     Xpos    dw  ?
  32.     Ypos    dw  ?
  33. ENDS
  34.  
  35. NumDefPal = 9
  36.  
  37. BLACK   =   0
  38. BLUE    =   255
  39. GREEN   =   254
  40. RED     =   253
  41. GREY1   =   252
  42. GREY2   =   251
  43. GREY3   =   250
  44. GREY4   =   249
  45. GREY5   =   248
  46. RED2    =   247
  47.  
  48. SCRW    =   80
  49. ────────────────────────────────────────────────────────────────────────────
  50. DefPal      PalStruc <20,00,00>,<25,25,25>,<35,35,35>,<45,45,45>,<56,56,56>
  51.             PalStruc <63,63,63>,<40,00,00>,<00,40,00>,<00,00,40>
  52.  
  53. Font8x8     db  256*8   dup (0) ;holding place for font
  54.  
  55. TextColor   db  RED
  56. ────────────────────────────────────────────────────────────────────────────
  57.     ;DS:BX = Ptr to list
  58.     ;   CX = # of entries
  59. PROC PrintList
  60.     pusha
  61. @@MSgLoop:
  62.     mov     si,[(MsgHdr PTR bx).Off]
  63.     mov     ax,[(MsgHdr PTR bx).Xpos]
  64.     mov     di,[(MsgHdr PTR bx).Ypos]
  65.     call    PrintText
  66.  
  67.     add     bx,(size MsgHdr)
  68.     dec     cx
  69.     jne     @@MsgLoop
  70.     popa
  71.     ret
  72. ENDP
  73.  
  74.     ;di = Ypos
  75.     ;ax = Xpos
  76.     ;ds:si = ptr to zero terminating string
  77. PROC PrintText
  78.     pusha
  79.     push    es
  80.     mov     es,[cs:VGAseg]
  81.  
  82.     imul    di,SCRW
  83.     add     di,ax
  84.  
  85. @@PrintLoop:
  86.     lodsb
  87.     or      al,al
  88.     je      @@Done
  89.     dec     al
  90.     je      @@ColorChange
  91.     dec     al
  92.  
  93.     movzx   bx,al
  94.     shl     bx,3        ;*8
  95.     mov     cl,8
  96.     mov     ch,[cs:TextColor]
  97.     mov     bp,di
  98. @@CopyChar:
  99.     mov     ah,[cs:Font8x8 + bx]
  100.     and     ah,1111b
  101.     @Set_Write_Plane
  102.     mov     [es:bp],ch
  103.     mov     ah,[cs:Font8x8 + bx]
  104.     shr     ah,4
  105.     @Set_Write_Plane
  106.     mov     [es:bp+1],ch
  107.  
  108.     add     bp,SCRW
  109.     inc     bx
  110.  
  111.     dec     cl
  112.     jne     @@CopyChar
  113.  
  114.     add     di,2
  115.     jmp     short @@PrintLoop
  116.  
  117. @@Done:
  118.     pop     es
  119.     popa
  120.     ret
  121. @@ColorChange:
  122.     lodsb
  123.     mov     [cs:TextColor],al
  124.     jmp     @@PrintLoop
  125. ENDP
  126.  
  127.     ;Immediatly after calling this routine, you MUST do a mode change
  128.     ; to properly restore the status of the VGA card.
  129. PROC StealFont
  130.     pusha
  131.     push    es ds
  132.     
  133.     mov     ax,0003h
  134.     int     10h             ;set VGA 80x25x16 char
  135.     mov     ax,1112h
  136.     mov     bl,0
  137.     int     10h             ;load 8x8 bios font into bank 0
  138.  
  139.     mov dx,3c4h             ;setup to read memory
  140.     mov ax,00402h
  141.     out dx,ax
  142.     mov ax,00604h
  143.     out dx,ax
  144.     ──
  145.     mov dx,3ceh
  146.     mov ax,00005h
  147.     out dx,ax
  148.     mov ax,00c06h
  149.     out dx,ax
  150.     mov ax,00204h
  151.     out dx,ax
  152.  
  153.     mov     ax,0b800h
  154.     mov     ds,ax
  155.     mov     ax,cs
  156.     mov     es,ax
  157.  
  158.     mov     di,offset Font8x8
  159.     mov     si,64               ;start w/ char #2, not #0 
  160.  
  161.     cld
  162.     mov     dx,255      ;grab 255 chars
  163. @@GrabLoop:
  164.     mov     cx,8
  165. @@UpHere:
  166.     lodsb
  167.     xor     ah,ah    
  168.  
  169.    REPT 8               ;mirror the byte- if this isn't done the chars will
  170.     shl     al,1        ; be backwards..
  171.     rcr     ah,1
  172.    ENDM
  173.     mov     al,ah
  174.     stosb
  175.     loop    @@UpHere
  176.     add     si,32-8
  177.     dec     dx
  178.     jne     @@GrabLoop
  179.  
  180.     pop     ds es
  181.     popa
  182.     ret
  183. ENDP
  184.  
  185. PROC SetDefPal
  186.     pusha
  187.     push    ds
  188.     mov     ax,cs
  189.     mov     ds,ax
  190.     mov     si,offset DefPal
  191.     mov     cx,NumDefPal
  192.     mov     al,256-NumDefPal
  193.     @WritePalette
  194.     pop     ds
  195.     popa
  196.     ret
  197. ENDP
  198.  
  199.